<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/jsp/head.jsp"%>
<%@ include file="/jsp/jslib.jsp"%>
<script type="text/javascript">
PAGE_CONFIG = {
	'MENU_INDEX' : 2,'LI_INDEX' : 2
};
</script>
</head>
<body>
<%@ include file="/jsp/banner.jsp"%>
<div class="am-cf admin-main">
	<%@ include file="/jsp/menu.jsp"%>
	<!-- content start -->
	<div class="admin-content">
		<div class="admin-content-body">
		
		<!-- ***** 分离出去 动态加载 start ***** -->
		<div class="am-g">
			<div class="am-u-sm-12 am-u-md-6 am-padd-top-20">
				<div class="am-btn-toolbar">
					<div class="am-btn-group am-btn-group-xs">
						<button id="new" type="button" class="am-btn am-btn-default"><span class="am-icon-plus"></span> 新增</button>
					</div>
					<div class="am-btn-group am-btn-group-xs">
						<button id="update" type="button" class="am-btn am-btn-default"><span class="am-icon-save"></span> 修改</button>
					</div>
					<div class="am-btn-group am-btn-group-xs">
						<button id="delete" type="button" class="am-btn am-btn-default"><span class="am-icon-trash-o"></span> 删除</button>
					</div>
				</div>
			</div>
		</div>
		
		<hr/>
		
		<div class="am-g">
		    <div class="am-u-sm-12">
		        <form class="am-form">
		            <table class="am-table am-table-striped am-table-hover table-main am-u-sm-6">
		                <thead>
		                    <tr>
		                        <th class="table-check"></th>
		                        <th class="table-id">序号</th>
		                        <th class="table-title">职位</th>
		                    </tr>
		                </thead>
		
		                <tbody>
			                <c:forEach items="${fgPositionList}" var="position">
		                		<tr>
			                    	<td><input type="radio" name="position" value='${position.positionId}' /></td>
			                    	<td id="position_id_${position.positionId}">${position.positionId}</td>
			                        <td id="position_name_${position.positionId}">${position.positionName}</td>
		                        </tr>
		                	</c:forEach>
	                    </tbody>
		            </table>
		
		            <!-- <div class="am-cf">
		                <div class="am-fr">
		                    <ul class="am-pagination">
		                        <li class="am-disabled"><a href="#">«</a></li>
		                        <li class="am-active"><a href="#">1</a></li>
		                        <li><a href="#">2</a></li>
		                        <li><a href="#">3</a></li>
		                        <li><a href="#">4</a></li>
		                        <li><a href="#">5</a></li>
		                        <li><a href="#">»</a></li>
		                    </ul>
		                </div>
		            </div> -->
		        </form>
		    </div>
		
		    </div>
		</div>
		
		<!-- ***** 分离出去 动态加载 end ***** -->
	</div>
	<!-- content end -->
</div>

<script type="text/javascript">
$("#delete").click(function(){
	var permission = '${sessionScope.permission}';
	if(permission != 2) {
		alert("无权限删除");
		return;
	}
	
	var val=$('input:radio[name="position"]:checked').val();
	if(val == null) {
		alert("请选择一行记录进行操作");
		return;
	}
	location.href= "${ctx}/position/delete?positionId=" + val;
});

$("#new").click(function(){
	window.location.href='${ctx}/biz_post_add.jsp'
});

$("#update").click(function(){
	var val=$('input:radio[name="position"]:checked').val();
	if(val == null) {
		alert("请选择一行记录进行操作");
		return;
	}
	var positionId = $("#position_id_"+val).text();
	var positionName = $("#position_name_"+val).text();
	window.location.href="${ctx}/biz_post_add.jsp?positionId="+positionId+"&positionName="+positionName;
});
</script>

</body>
</html>